package com.TeamJigsaw.DanteTrail.Views;

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionListener;

import javax.swing.*;

import com.TeamJigsaw.DanteTrail.Views.Interfaces.RiverViewInterface;
import net.miginfocom.swing.MigLayout;

public class RiverView extends JPanel implements RiverViewInterface{

	private JButton btnForward;
	private JRadioButton rdbtnNewRadioButton, rdbtnNewRadioButton_1, rdbtnFordRiver;
	private JLabel lblImage;
	private ButtonGroup group;
	private String htmlStart, htmlEnd;
	public RiverView()
	{
		setSize(new Dimension(700,700));
		setLayout(new MigLayout("", "[100:100:100][][][100:100:100]", "[50:50:50][][30:30:30][][][][][]"));
		htmlStart = "<html><font size=\"4\" color=\"#FFFFFF\"><b>";
		htmlEnd = "</b></font></html>";
		
		initialize();
	}
	
	public void initialize()
	{
		group = new ButtonGroup();
		lblImage = new JLabel("IMAGE");
		add(lblImage, "cell 1 1 2 1");
		
		rdbtnNewRadioButton = new JRadioButton(htmlStart+"Pay for Ferrey"+htmlEnd);
		add(rdbtnNewRadioButton, "cell 2 3");
		
		group.add(rdbtnNewRadioButton);
		group.setSelected(rdbtnNewRadioButton.getModel(), true);
		
		rdbtnNewRadioButton_1 = new JRadioButton(htmlStart+"Caulk Wagon (Play Minigame)"+htmlEnd);
		add(rdbtnNewRadioButton_1, "cell 2 4");
		group.add(rdbtnNewRadioButton_1);
		
		
		
		rdbtnFordRiver = new JRadioButton(htmlStart+"Ford River"+htmlEnd);
		add(rdbtnFordRiver, "cell 2 5");
		group.add(rdbtnFordRiver);
		
		btnForward = new JButton("Proceed");
		add(btnForward, "cell 2 7,grow");
	}

	@Override
	public void setNextButtonListener(ActionListener listen) {
		btnForward.addActionListener(listen);
		
	}

	@Override
	public void setBackButtonListener(ActionListener listen) {
		//btnBack.addActionListener(listen);
		
	}

	@Override
	public int getSelection() {
		if(group.getSelection() == rdbtnNewRadioButton.getModel())
			return 1;
		else if(group.getSelection() == rdbtnNewRadioButton_1.getModel())
				return 2;
		else if(group.getSelection() == rdbtnFordRiver.getModel())
			return 3;
		return 0;
	}

	@Override
	public void setImage(ImageIcon image) {
		lblImage = new JLabel(image);
		add(lblImage, "cell 1 1 2 1");
		
	}
	
	@Override
	public boolean listenersExist() {
		if(btnForward.getActionListeners().length > 0)
			return true;
		
		return false;
	}
	
	@Override
	public void paintComponent(Graphics g) {
		ImageIcon img = new ImageIcon("resources\\stone_texture.png");
	    g.drawImage(img.getImage(), 0, 0, null);
	  }
}
